package com.tbit.uqbike.service.business.impl;


import com.tbit.uqbike.constant.RedisConstant;
import com.tbit.uqbike.object.pojo.MpBrandConfig;
import com.tbit.uqbike.service.base.RedisService;
import com.tbit.uqbike.service.business.MpBrandConfigService;
import com.tbit.uqbike.webmanager.dao.core.MpBrandConfigDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 小程序配置
 *
 * @author Leon
 * 2019年12月24日 下午9:04:40
 */
@Service("mpBrandConfigService")
public class MpBrandConfigServiceImpl implements MpBrandConfigService {
    @Autowired
    private MpBrandConfigDao mpBrandConfigDao;
    @Autowired
    private RedisService redisService;

    @Override
    public MpBrandConfig getByAccountId(Integer accountId) {
        return mpBrandConfigDao.getByAccountId(accountId);
    }

    @Override
    public void add(MpBrandConfig mpBrandConfig) {
        MpBrandConfig mpBrandConfigDB = getByAccountId(mpBrandConfig.getAccountId());
        if (mpBrandConfigDB != null) {
            mpBrandConfigDao.edit(mpBrandConfig);
            /**清除redis数据*/
            redisService.del(RedisConstant.MPCONFIG_KEY_PREFIX + mpBrandConfig.getAccountId());
        } else {
            mpBrandConfigDao.add(mpBrandConfig);
        }
    }


}
